#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QTimer>
#include "map.h"
#include "heroplane.h"
#include "enemyplane.h"
#include "bomb.h"

namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = 0);
    ~Widget();

    //初始化场景
    void initScene();

    //启动游戏
    void playGame();

    //更新元素坐标
    void updatePosition();

    //绘制到屏幕
    void paintEvent(QPaintEvent* e);

    //重写鼠标移动事件
    void mouseMoveEvent(QMouseEvent* e);

    //地图对象
    Map m_map;
    //飞机对象
    HeroPlane m_hero;

    //敌机出场
    void enemyToScene();

    //敌机数组
    EnemyPlane m_enemys[ENEMY_NUM];

    //碰撞检测
    void collisionDetection();

    //敌机出场间隔记录
    int m_recorder;

    //定时器
    QTimer m_Timer;

    //爆炸数组
    Bomb m_bomns[BOMB_NUM];

private:
    Ui::Widget *ui;
};

#endif // WIDGET_H
